import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FlowingVO, FlowingForm, FlowingQuery } from '@/api/business/flowing/types';

/**
 * 查询用户积分流水列表
 * @param query
 * @returns {*}
 */

export const listFlowing = (query?: FlowingQuery): AxiosPromise<FlowingVO[]> => {
  return request({
    url: '/business/flowing/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户积分流水详细
 * @param userFlowingId
 */
export const getFlowing = (userFlowingId: string | number): AxiosPromise<FlowingVO> => {
  return request({
    url: '/business/flowing/' + userFlowingId,
    method: 'get'
  });
};

/**
 * 新增用户积分流水
 * @param data
 */
export const addFlowing = (data: FlowingForm) => {
  return request({
    url: '/business/flowing',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户积分流水
 * @param data
 */
export const updateFlowing = (data: FlowingForm) => {
  return request({
    url: '/business/flowing',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户积分流水
 * @param userFlowingId
 */
export const delFlowing = (userFlowingId: string | number | Array<string | number>) => {
  return request({
    url: '/business/flowing/' + userFlowingId,
    method: 'delete'
  });
};
